package com.zsrt.javaweb.bbu.book.service.impl;

import com.zsrt.javaweb.bbu.book.dao.BookShopDao;
import com.zsrt.javaweb.bbu.book.service.BookShopService;

public class BookShopServiceImpl implements BookShopService {
	
	private BookShopDao bookShopDao;
	
	public void setBookShopDao(BookShopDao bookShopDao) {
		this.bookShopDao = bookShopDao;
	}



	@Override
	public void purchase(String username, int isbn) {
//		try {
//			//单位 毫秒
//			Thread.sleep(3000);
//		} catch (InterruptedException e) {
//			e.printStackTrace();
//		}
		
		//1 获取书的单价
		int price = bookShopDao.findBookPriceByIsbn(	isbn);
		
		//2 更新书的库存  -1
		bookShopDao.updateBookStock(	isbn);
		
		//3 更新用户余额  
		bookShopDao.updateUserAccount(username, price);

	}

}
